'  ==========================================================================
'  |                                                                        |
'  | SQLitening Example A                                                   |
'  |                                                                        |
'  ==========================================================================
'  This is a simple demonstration that shows how to open and
'  use an SQLite database in both local and remote modes. Remote
'  mode requires that you have already started the SQLitening
'  server, otherwise an error will occur.
'  ==========================================================================
'  PUBLIC DOMAIN SOFTWARE
'  The author or authors of this code dedicate any and all
'  copyright interest in this code to the public domain.
'  Anyone is free to copy, modify, publish, use, compile,
'  sell, or distribute the original code, either in source
'  code form or as a compiled binary, for any purpose,
'  commercial or non-commercial, and by any means.
'  Fred Meier - July 2010
'  ==========================================================================

%DebugEXE = 1

#Dim All

#Compile Exe "..\Bin\DEBUG\SQLitening\DebugEXE.Exe"
#Include "..\Src\SQLiteningU.bas"

'==============================<[ Main ]>==============================
Function PBMain()

   Local NumRecs As Long
   Local lStart  As Double
   Local lEnd    As Double
   Local st      As String


   ' Connect to the server -- omit this call to run in local mode
   ' or use the slSetProcessMods function to explicitly switch to
   ' local mode without dropping the server connection.  No server
   ' name will default to LocalHost.
   slConnect


   '//
   '//  TEST #1  - Client/Server remote mode
   '//

   ' Save our starting time
   lStart = Timer

   ' Open the sample database
   slOpen "sample.db3"

   ' Select record set (should be 10,000 rows returned)
   slSel "Select * from Parts"

   ' Process records
   NumRecs = 0
   Do While slGetRow
      Incr NumRecs
      ' When a row is returned, you use the slF, slFN, slFX, slFNX functions.
      ' Example:
      ' lsA = slF(1) & ", " & slF(2) & "," & slFN("Product")
   Loop

   ' Save the time it took to run this test so we can display it later.
   lEnd = Timer - lStart

   ' Build the string that will display the results
   st = st & _
        "Test 1:  Retrieve " & Format$(NumRecs) & " rows from server (LocalHost)." & _
        "  Time: " & Format$(lEnd, "##.0000") & " seconds." & $CrLf & $CrLf

   ? st
   
End Function
